package com.tuanzi.loan.web.lazy.system;

import org.springframework.data.domain.Page;

import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.vo.request.system.ProcessDefinitionSearchRequest;
import com.tuanzi.loan.workflow.service.WorkflowManagerService;
import com.tuanzi.loan.workflow.vo.ProcessDefinitionResponse;

/**
 * @author Ray 2017/09/21
 */
public class WorkflowDefinitionLazyDataModel extends BaseLazyDataModel<ProcessDefinitionSearchRequest, ProcessDefinitionResponse> {

	private WorkflowManagerService workflowManagerService = SpringContextHolder.getBean(WorkflowManagerService.class);
	private static final long serialVersionUID = -4670419347550704982L;

	public WorkflowDefinitionLazyDataModel(ProcessDefinitionSearchRequest searchRequest) {
		super(searchRequest);
	}

	@Override
	protected Page<ProcessDefinitionResponse> doLoad(PageSearcher<ProcessDefinitionSearchRequest> pageSearcher) {
		return workflowManagerService.listLastVersionProcessDefinition(pageSearcher);
	}
}
